class DamageJudge2Controller < ApplicationController
  def index
    @order_item = get_order_item
    if request.post?
      position = get_position
      work_judge = @order_item.work_judge
      damage_degree = params[:damage_degree]
      if damage_degree == "塗膜のみ"
        work_judge = "サフから"
      end
      if damage_degree == "へこみ５ｍｍ以下"
        work_judge = "鈑金パテから"
      end
      if damage_degree == "へこみ５ｍｍ以上"
        if position.material == "樹脂"
          work_judge = "鈑金パテから"
        else
          work_judge = "凹み修正から"
        end
      end
      @order_item.work_judge = work_judge
      @order_item.damage_degree = damage_degree
      
      if damage_degree == "折れ千切れ"
        if position.material == "樹脂"
          redirect_to :action => "break" and return
        else
          redirect_to :controller => :damage_judge3, :action => :index and return
        end
      end
      redirect_to :action => :get_area
    end
  end
  
  def get_area
    @order_item = get_order_item
    if request.post?
      @order_item.area_x = params[:area_x]
      @order_item.area_y = params[:area_y]
      difficulty_judge = true
      redirect_to :controller => :damage_judge, :action => :get_metal_index, :difficulty_judge => difficulty_judge
    end
  end
  
  def break
    @order_item = get_order_item
    if request.post?
      @order_item.paint_completion = params[:paint_completion]
      if params[:paint_completion] == "F"
        @order_item.paint_index = 2.5
      else
        @order_item.paint_index = 0.0
      end
      redirect_to :controller => :damage_judge3, :action => :index
    end
  end
  
end
